﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace moc.Models
{
    public class MocDbContext:DbContext
    {       
        public DbSet<AdminInfo> AdminInfo { get; set; }
        public DbSet<AdminRole> AdminRole { get; set; }
        public DbSet<CustomerLogin> CustomerLogin { get; set; }
        public DbSet<CustomerInfo> CustomerInfo { get; set; }
        public DbSet<ProductCategory> ProductCategory { get; set; }
        public DbSet<ProductInfo> ProductInfo { get; set; }
        public DbSet<ProductComment> ProductComment { get; set; }
        public DbSet<OrderCart> OrderCart { get; set; }
        public DbSet<OrderMaster> OrderMaster { get; set; }
        public DbSet<OrderDetail> OrderDetail { get; set; }

        
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseMySql("server=localhost;database=MocDb;user=root;password=root;");
        }
        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.Entity<AdminInfo>().HasKey(a => a.Admin_id);
            builder.Entity<AdminRole>().HasKey(r => r.Role_id);
            builder.Entity<CustomerLogin>().HasKey(c => c.Customer_id);
            builder.Entity<CustomerInfo>().HasKey(c => c.Customer_inf_id);
            builder.Entity<ProductCategory>().HasKey(p => p.Category_id);
            builder.Entity<ProductInfo>().HasKey(p => p.Product_id);
            builder.Entity<ProductComment>().HasKey(p => p.Comment_id);
            builder.Entity<OrderCart>().HasKey(o => o.Cart_id);
            builder.Entity<OrderMaster>().HasKey(o => o.Order_id);
            builder.Entity<OrderDetail>().HasKey(o => o.Detail_id);
            base.OnModelCreating(builder); 
        }
        
    }
}
